package com.googlecode.curvedmetromaps.core.geometry;

public class BSplineCurveFitter {

	public static void CreateBSplinePolysegment(double[] mSamples, int mDegree, int mNumCtrlPoints) {
		int mDimension = 3;
		assert mSamples.length % mSamples.length == 0 : "Sample size not a multiple of the dimension";
		int mNumSamples = mSamples.length / mDimension;

		// Create the curve from the current parameters.
		BSplineCurveFit mSpline = new BSplineCurveFit(mDimension, mNumSamples, mSamples, mDegree, mNumCtrlPoints);
		System.out.println("Done");

		// Sample it the same number of times as the original data.
		/*
		 * VertexFormat* vformat = VertexFormat::Create(2,
		 * VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
		 * VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0); int vstride =
		 * vformat->GetStride();
		 * 
		 * VertexBuffer* vbuffer = new0 VertexBuffer(mNumSamples, vstride);
		 * VertexBufferAccessor vba(vformat, vbuffer);
		 * 
		 * float mult = 1.0f/(mNumSamples - 1); int i; for (i = 0; i <
		 * mNumSamples; ++i) { mSpline->GetPosition(mult*i,
		 * (float*)vba.Position<Vector3f>(i)); }
		 * 
		 * Polysegment* segment = new0 Polysegment(vformat, vbuffer, true);
		 * segment->SetEffectInstance(mEffect->CreateInstance());
		 * mScene->SetChild(1, segment);
		 * 
		 * // Compute error measurements. mAvrError = 0.0f; mRmsError = 0.0f;
		 * for (i = 0; i < mNumSamples; ++i) { Vector3f diff = mSamples[i] -
		 * vba.Position<Vector3f>(i); float sqrLength = diff.SquaredLength();
		 * mRmsError += sqrLength; float length = Mathf::Sqrt(sqrLength);
		 * mAvrError += length; } mAvrError /= (float)mNumSamples; mRmsError /=
		 * (float)mNumSamples; mRmsError = Mathf::Sqrt(mRmsError);
		 */
	}
}
